package com.yangxinxin.lesson.config;

import com.yangxinxin.lesson.interceptor.TokenInceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/** @Author yangxinxin
 * @Description //TODO
 * @Date 18:55 2020/2/21
 * @Param
 * @return
 **/
@Configuration
public class WebAppConfig  implements WebMvcConfigurer {
    /**将自定义拦截器注入到spring容器中***/
    @Bean
    public TokenInceptor tokenInceptor(){
        return  new TokenInceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInceptor()).addPathPatterns("/api/**").excludePathPatterns("/api/user/login","/api/user/register","/api/user/code/*");

    }
}
